package Java0311;

import java.util.Scanner;

public class Array15 {
    public static void main(String[] args) {
        //*15：把分解质因数的结果放入数组
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个正整数：");
        int number1 = scanner.nextInt();
        // System.out.print(number + "=");
        int temp = 0;
        int i = 2;
        int number = number1;
        while (number1 != 1) {
            if (number1 % i == 0) {
                number1 = number1 / i;
                temp++;
                continue;
            }
            i++;
        }
        int[] array = new int[temp];
        //在第一个while循环里确定了因数的个数（=数组长度），i需要重置为2
        i = 2;
        //数组下标
        int j = 0;
        while (number != 1) {
            if (number % i == 0) {
                number = number / i;
                //把因数写进数组
                array[j] = i;
                j++;
//              if (number == 1) {
//                  System.out.print(i);
//              } else {
//                  System.out.print(i + "x");
//              }
                continue;
            }
            i++;
        }
        //打印数组
        for (int x = 0; x < array.length; x++) {
            System.out.print(array[x] + "\t");
        }
    }
}
